using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;


/// <summary>
/// loads error list from XML file
/// </summary>
public static class FileLoader
{
	/// <summary>
	/// Loads error list from XML file and puts it into the DataTable.
	/// </summary>
	/// <param name="filePath">Path to the XML file with error list.</param>
	/// <returns>Filled DataTable</returns>
	public static DataTable Fill(string filePath)
	{
		DataSet ds = new DataSet();
		XmlReader reader = null;
		try
		{
			// reading data from XML file
			reader = XmlReader.Create(filePath);
			ds.ReadXml(reader);
		}
		catch (Exception)
		{
			// throwing eny general exeption
			throw;
		}
		finally
		{
			// closing XmlReader
			if (reader != null)
				reader.Close();
		}
		// if DataTable was successfully created - returning it
		if (ds.Tables.Count > 0) return ds.Tables[0];
		return null; 
	}
}
